package com.tianqu.tms.www.bid.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.AucCarInfo;
import com.tianqu.tms.www.bid.controller.BidCarSerchAddResultController;
import com.tianqu.tms.www.bid.viewhelper.BidCarSerchInputViewHelper;

/**
 * 参拍登记-车辆信息确认
 * @author mufeiyu
 *
 */
public class BidCarSerchAddConfirmAction extends TmsAction {
	private Logger logger = Logger.getLogger(BidCarSerchAddConfirmAction.class);
	public static String CARMODIFY = "carmodify";
	private static final String OFF="off";
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {

		BidCarSerchInputViewHelper view = (BidCarSerchInputViewHelper) uc
		.getAttribute(TmsConstants.VIEWHELP);
		
		String vin = (String) uc.getParameter("vin");
		vin = StringUtil.toUpperCase(vin);
		AucCarInfo aucCar = AucCarInfo.getInstance();
		aucCar = aucCar.getaucCar(vin);

		BidCarSerchAddResultController controller = new BidCarSerchAddResultController();
		String sysPath = request.getSession().getServletContext().getRealPath(
				"/").replace("/tmsweb", "");
		uc.setAttribute("sysPath", sysPath);
		controller.execute(uc);
		
		request.setAttribute(OFF, "信息添加完了");
		uc.removeAttribute(TmsConstants.VIEWHELP);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		if (!StringUtil.isNullOrBlank(request.getParameter("flg"))
				&& "2".equals(request.getParameter("flg"))) {

			return mapping.findForward("modify");
		} else {
			return mapping.findForward(TmsConstants.SUCCESS);
		}
	}
}
